//package com.sgb.kjwl.view.ui.fragment.shop;
//
//import android.content.Context;
//import android.databinding.DataBindingUtil;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.support.v7.widget.LinearLayoutManager;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//
//import com.sgb.kjwl.AppFragment;
//import com.sgb.kjwl.R;
//import com.sgb.kjwl.databinding.FragmentShopDeviceChildBinding;
//import com.sgb.kjwl.di.shopping.DaggerShoppingFragComponent;
//import com.sgb.kjwl.di.shopping.ShoppingFragModule;
//import com.sgb.kjwl.model.entity.ShopGoodsInfoEntity;
//import com.sgb.kjwl.view.ui.activity.device.DeviceDetailActivity;
//import com.sgb.kjwl.view.ui.activity.machine.MachineOutActivity;
//import com.sgb.kjwl.view.ui.activity.self.shop.ShopGoodsInfoActivity;
//import com.sgb.kjwl.view.ui.activity.self.shop.ShopInfoActivity;
//import com.sgb.kjwl.view.ui.adapter.shopping.ShopMachineAdapter;
//import com.sgb.kjwl.viewmodel.shopping.ShopDeviceChildModel;
//import com.swgk.core.base.di.AppComponent;
//import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
//import com.swgk.core.xrecyclerview.XRecyclerView;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import javax.inject.Inject;
//
///**
// * Author chenfangkai
// */
//public class ShopDeviceChildFragment extends AppFragment {
//    public static final String SHOP_ID = "shop_id";
//    private ShopInfoActivity activity;
//    private FragmentShopDeviceChildBinding binding;
//    private ShopMachineAdapter adapter;
//    private List<ShopGoodsInfoEntity> stringList;
//    private Map map;
//    private String shopId;
//    @Inject
//    ShopDeviceChildModel viewModel;
//
//    @Override
//    public void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//    }
//
//    @Override
//    public void onAttach(Context context) {
//        super.onAttach(context);
//        if (context instanceof ShopInfoActivity) {
//            activity = (ShopInfoActivity) context;
//        }
//    }
//
//    @Nullable
//    @Override
//    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_shop_device_child, container, false);
//        return binding.getRoot();
//    }
//
//    @Override
//    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
//        super.onActivityCreated(savedInstanceState);
//        initView();
//        init();
//    }
//
//    @Override
//    protected void setupFragmentComponent(AppComponent appComponent) {
//        DaggerShoppingFragComponent.builder()
//                .appComponent(appComponent)
//                .shoppingFragModule(new ShoppingFragModule(this))
//                .build()
//                .inject(this);
//    }
//
//    public static ShopDeviceChildFragment newInstance(String shopId) {
//        ShopDeviceChildFragment fragment = new ShopDeviceChildFragment();
//        Bundle bundle = new Bundle();
//        bundle.putString(SHOP_ID, shopId);
//        fragment.setArguments(bundle);
//        return fragment;
//    }
//
//    private void initView() {
//        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
//        shopId = (String) getArguments().get(SHOP_ID);
//        if (adapter == null) {
//            adapter = new ShopMachineAdapter(getActivity(), null);
//        }
//        binding.rlvList.setLayoutManager(layoutManager);
//        binding.rlvList.setAdapter(adapter);
//        adapter.setOnItemClick(new AdapterOnItemClick<ShopGoodsInfoEntity>() {
//            @Override
//            public void onItemClick(ShopGoodsInfoEntity s, int position) {
//                DeviceDetailActivity.start(getActivity(), s.getId());
//            }
//        });
//
//        binding.rlvList.setLoadingListener(new XRecyclerView.LoadingListener() {
//            @Override
//            public void onRefresh() {
//                viewModel.queryListByStore(map);
//            }
//
//            @Override
//            public void onLoadMore() {
//                viewModel.loadMore(map);
//            }
//        });
//    }
//
//
//    private void init() {
//        map = new HashMap();
//        map.put("id", shopId);
//        map.put("channel", "equipment");
//        viewModel.queryListByStore(map);
//    }
//
//
//
//    public void refresh(List<ShopGoodsInfoEntity> stringList) {
//        binding.emptyView.setVisibility(View.GONE);
//        binding.rlvList.setVisibility(View.VISIBLE);
//        binding.rlvList.setLoadingMoreEnabled(true);
//        adapter.setDatas(stringList);
//        binding.rlvList.refreshComplete();
//        if (adapter.getItemCount() >= viewModel.total) {
//            binding.rlvList.setLoadingMoreEnabled(false);
//        }
//    }
//
//
//    public void loadMore(List<ShopGoodsInfoEntity> stringList) {
//        adapter.addDatas(stringList);
//        binding.rlvList.loadMoreComplete();
//        if (adapter.getItemCount() >= viewModel.total) {
//            binding.rlvList.setLoadingMoreEnabled(false);
//        }
//    }
//
//    public void empty() {
//        binding.rlvList.refreshComplete();
//        binding.emptyView.setVisibility(View.VISIBLE);
//    }
//
//    public void loadMoreComplete() {
//        binding.rlvList.loadMoreComplete();
//    }
//
//}
